package com.tanhua.server.controller;

import com.tanhua.common.utils.UserThreadLocal;
import com.tanhua.server.service.TodayBestService;
import com.tanhua.server.vo.TodayBest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenjun
 * @date 2021/8/9
 */
@Slf4j
@RestController
@RequestMapping("/tanhua")
public class TodayBestController {

    @Autowired
    private TodayBestService todayBestService;

    /**
     * 查询今日佳人
     *
     * @param //token
     * @return org.springframework.http.ResponseEntity<com.tanhua.server.vo.TodayBest>
     * @date 2021/8/10
     */
    @GetMapping("/todayBest")
    public ResponseEntity<TodayBest> queryTodayBast() {
        try {
            TodayBest todayBest = todayBestService.queryTodayBast();
            if (todayBest != null) {
                return ResponseEntity.ok(todayBest);
            }
        } catch (Exception e) {
            log.error("查询今日佳人出错~ userId = " + UserThreadLocal.get().getId(), e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }
}
